package com.mini.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @param <T>
 */
public class PageResultVO<T> implements Serializable {

    private static final long serialVersionUID = -6293650025117429528L;

    /**
     * 默认构造方法
     */
    public PageResultVO() {

    }

    /**
     * 分页查询结果构造器
     *
     * @param total 总记录数
     * @param rows  每页记录
     */
    public PageResultVO(long total, List<T> rows) {
        this.total = total;
        this.rows = rows;
    }

    /**
     * 总记录数
     */
    private long total = 0;

    /**
     * 每页数据记录
     */
    private List<T> rows = new ArrayList<>();

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"total\":")
                .append(total);
        sb.append(",\"rows\":")
                .append(rows);
        sb.append('}');
        return sb.toString();
    }
}
